package online.flytool.base.check;

/**
 * 断言测试
 * @author ：lingchong
 * date ：2022/7/16 12:10
 * modified By：
 * @version: 0.0.1$
 */
public class Assert {

    /**
     * 断言对象是否不为{@code null} ，如果为{@code null} 抛出{@link IllegalArgumentException} 异常
     *
     *
     * @param object 被检查对象
     * @return 非空对象
     * @throws IllegalArgumentException if the object is {@code null}
     */
    public static void notNull(Object object) throws IllegalArgumentException {
        if(object==null){
            throw new IllegalArgumentException("[Assertion failed] - this argument is required; it must not be null");
        }
    }

    /**
     * 断言对象是否不为{@code null} ，如果为{@code null} 抛出{@link IllegalArgumentException} 异常
     *
     * @param object 被检查对象
     * @return 非空对象
     * @throws IllegalArgumentException if the object is {@code null}
     */
    public static void notNull(Object object,String msg) throws IllegalArgumentException {
        if(object==null){
            throw new IllegalArgumentException(msg);
        }
    }

}